var setting = {};
$.get("/main/getAllTree", function(data) {
	zNodes = data
	//正常加载信息
	if(window.sessionStorage.getItem("asd")) {
		var asd = window.sessionStorage.getItem("asd");
		zNodes = JSON.parse(asd).concat(zNodes); //转换成JSON格式
	}

	var setting = {
		check: {
			enable: true
		},
		data: {
			key: {
				title: "t"
			},
			simpleData: {
				enable: true
			}
		},
		callback: {
			onMouseDown: onMouseDown,
			onCheck:onCheck
		}
	};

	var log;

	function onMouseDown(event, treeId, treeNode) {
		showLog((treeNode ? treeNode.name : "root"), "down");
	}

	function showLog(str, logType) {
		log = $("#log" + "_" + logType);
		log.append("<li>" + str + "</li>");
		if(log.children("li").length > 1) {
			log.get(0).removeChild(log.children("li")[0]);
		}
	}

	$(document).ready(function() {
		$.fn.zTree.init($("#treeDemo"), setting, zNodes);
	});
	function onCheck(e,treeId,treeNode){
	    var treeObj=$.fn.zTree.getZTreeObj("treeDemo"),
	    nodes=treeObj.getCheckedNodes(true),
	    v="";
	    for(var i=0;i<nodes.length;i++){
		    v+=nodes[i].name + ",";
//		    alert(nodes[i].id); //获取选中节点的值
//		    alert(v); //获取选中节点的值
	    }
	    
	    
	    }
})